package org.openclinic.domain;

// Generated Nov 18, 2012 4:21:03 PM by Hibernate Tools 4.0.0

import java.util.Date;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.DiscriminatorColumn;
import javax.persistence.DiscriminatorType;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.OneToOne;
import javax.persistence.PrimaryKeyJoinColumn;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

import org.hibernate.validator.constraints.Email;
import org.hibernate.validator.constraints.NotBlank;

/**
 * User generated by hbm2java
 */
@Entity
@Table(name = "openclinic_user", schema = "public")
@DiscriminatorColumn(name = "bond", discriminatorType = DiscriminatorType.INTEGER)
public abstract class User implements java.io.Serializable {

	private static final long serialVersionUID = 6548095357216195932L;
	
	private Long userId;
	
	@NotBlank
	private String cpf;
	
	@NotBlank
	private String name;
	
	private Date birthdate;
	
	private int bond;
	
	@NotBlank
	private String gender;
	
	@NotBlank
	private String phone;
	
	private String cellPhone;
	
	@Email
	private String email;
	
	private Date creationDate;
	
	private Date lastUpdate;
	
	private Address address;

	public User() {
	}

	public User(Long userId, String cpf, String name, Date birthdate, int bond, String gender, String phone, String cellPhone,
			Date creationDate, Date lastUpdate) {
		this.userId = userId;
		this.cpf = cpf;
		this.name = name;
		this.birthdate = birthdate;
		this.bond = bond;
		this.gender = gender;
		this.phone = phone;
		this.cellPhone = cellPhone;
		this.creationDate = creationDate;
		this.lastUpdate = lastUpdate;
	}

	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	@Column(name = "user_id", unique = true, nullable = false)
	public Long getUserId() {
		return this.userId;
	}

	public void setUserId(Long userId) {
		this.userId = userId;
		
		if (address != null) {
			address.setUserId(this.userId);
		}
	}

	@Column(name = "cpf", nullable = false, length = 14)
	public String getCpf() {
		return this.cpf;
	}

	public void setCpf(String cpf) {
		this.cpf = cpf;
	}

	@Column(name = "name", nullable = false, length = 100)
	public String getName() {
		return this.name;
	}

	public void setName(String name) {
		this.name = name;
	}

	@Temporal(TemporalType.DATE)
	@Column(name = "birthdate", nullable = false, length = 13)
	public Date getBirthdate() {
		return this.birthdate;
	}

	public void setBirthdate(Date birthdate) {
		this.birthdate = birthdate;
	}

	@Column(name = "bond", nullable = false, insertable = false, updatable = false)
	public int getBond() {
		return this.bond;
	}

	public void setBond(int bond) {
		this.bond = bond;
	}

	@Column(name = "gender", nullable = false, length = 1)
	public String getGender() {
		return this.gender;
	}

	public void setGender(String gender) {
		this.gender = gender;
	}

	@Column(name = "phone", nullable = false)
	public String getPhone() {
		return this.phone;
	}

	public void setPhone(String phone) {
		this.phone = phone;
	}

	@Column(name = "cell_phone", nullable = false)
	public String getCellPhone() {
		return this.cellPhone;
	}

	public void setCellPhone(String cellPhone) {
		this.cellPhone = cellPhone;
	}

	@Column(name = "email", length = 100)
	public String getEmail() {
		return this.email;
	}

	public void setEmail(String email) {
		this.email = email;
	}

	@Temporal(TemporalType.TIMESTAMP)
	@Column(name = "creation_date", nullable = false, length = 13)
	public Date getCreationDate() {
		return this.creationDate;
	}

	public void setCreationDate(Date creationDate) {
		this.creationDate = creationDate;
	}

	@Temporal(TemporalType.TIMESTAMP)
	@Column(name = "last_update", nullable = false, length = 13)
	public Date getLastUpdate() {
		return this.lastUpdate;
	}

	public void setLastUpdate(Date lastUpdate) {
		this.lastUpdate = lastUpdate;
	}

	@OneToOne(fetch = FetchType.EAGER, cascade = CascadeType.ALL)
	@PrimaryKeyJoinColumn
	public Address getAddress() {
		return this.address;
	}

	public void setAddress(Address address) {
		this.address = address;
	}
}